// JavaScript Document
//version:1.06.001

//btoa:base64
"use strict";
(typeof($Q)=='function')?'':
((function(){
	
	//基础用户对象信息
	var k = {
		
		_loading:null,//loading元素信息
		
		//参数配置信息
		_config:{
			LOADING_IMG:null,//是否使用图片的模式加载loading，如果不为空，则视为加载loading图片
			LOADING_IMG_PROTATE:0,//如果旋转每次旋转的角度，配置为0则不旋转	
			LOADING_TIMER:100,//定时器
			LOADING_SCALE:'circle',//loading加载场景
			CARD_HEAD_H:40,//卡片head的高度px
			CARD_FOOT_H:40,//卡片foot的高度px
			DEBUG:false,//系统调试模式，开启后系统debug信息会启动
			//关于图片自动上传模块的相关配置
			UPLOAD:{
				ACTION:'',//配置的默认上传地址，不配置则自动默认当前地址
				PARAMS:{},//默认调用的额外配置，默认为空，使用post的方式上传
				SEC_SIZE:'1M',//默认使用切片模式，如果配置这个大小则使用切片的方式上传
			},
		},
		debug:function(msg,key){
			if(k._config.DEBUG){
				msg = 'KuoqiJs ['+key+'] warn :'+k._f.stringifyJSON(msg);
				console.log(msg)	
			}	
		},
		
		//判断是否重复
		index:{
			msg:null,//msg	
		},
		
		//简单的错误信息，是返回的那种啦
		error:function(code,msg,data){
			return {errcode:code,errmsg:msg,data:data};
		},
		
		//注册并维护一个顶层的对象信息
		message:((function(){
			//设置
			var pkg = {
				set:function(n,v){
					if(window.top.$Q.ID==$Q.ID){
						return this.list[n] = v;
					}else{
						return window.top.$Q.process.set(n,v);
					}
				},
				get:function(n){
					if(window.top.$Q.ID==$Q.ID){
						return this.list[n];
					}else{
						return window.top.$Q.process.get(n);
					}
				},//获取
				list:{}//列表信息
			};
			if(!window.top.$Q){
				window.top.$Q = {
					ID:'_'+Math.ceil(Math.random() * 100000),
					process:pkg,	
				};
			};
			return pkg;
		})()),
		
		//待初始化数据列表信息，嘻嘻
		ready:{
			list:[],
			push:function(ele){
				this.list.push(ele);
			},
			each:function(callback){
				for(var i=0;i<this.list.length;i++){
					callback&&callback(i,this.list[i]);
				}
			},
			callback:function(){
				this.each(function(i,item){
					typeof(item)=='function'&&item();
				})
			}
		},
		_e_e:{
			version:'1.06',	
			
			addClass:function(className){
				this.each(function(i,e){
					if(!k._e_e.selector(this).hasClass(className)){
						if(this.classList==0){
							this.className = className;
						}else{
							(this.className += ' '+className)
						}
					}
				});
				return this;	
			},
			
			
			after:function(s){
				if(s==undefined){
					return k._e_e.selector(this.next());
				}else{
					if(this.next().length==0){
						return this.parent().append(s);	
					}else{
						if(s&&s.type&&s.type=='KnodeList'){
							var h = s.first(true);
						}else if(Object.prototype.toString.call(s).indexOf('[object HTML')==0){
							var h = s;
						}else{
							//string
							var h = k._f.parseHTML(s);
							h = h[0];
						};
						return k._e_e.selector(this.parent().first(true).insertBefore(h,this.next().first(true)));
					}
				};
			},
			
			//异步同步内容信息
			ajaxConts:function(opts){
				var ths = this;
				opts = k._f.optionsInput(opts,{
					action:'',	
					data:{},
					method:'get',
				});
				var p = new k._f.proxy(opts);
				p.success = function(a,b,c){
					ths.html(a);
                    opts.success&&opts.success();
				}
				p.error = function(){
					ths.html('<span>404</span>');
                    opts.error&&opts.error();
				}
				p.send();
			},
			
			//异步上传表单信息
			ajaxSubmit:function(opts){
				try{
					var ths = this;
					if(this.isValid()){
						var data =this.getFormdata(this);
						var action = ths.getAttr('action');
						var method = ths.getAttr('method');
						opts = k._f.optionsInput(opts,{
							action:action?action:"",	
							method:method?method:'get',
							data:{},
						});
						var proxy = k._f.proxy(opts);
						proxy.setDatas(data);
						proxy.setDatas(opts.data);
						proxy.send();
					}else{
						k._f.msg('Invalid form submission');
					};
					
				}catch(err){console.log(err);};
			},
			
			//动画效果呀
			//todo--这是一个大模块，动画效果模块




			animation:function(opts){
				opts = k._f.optionsInput(opts,{
					'focusElement':this,
					'rotateZangle':0,//旋转的时候Z转角
					'rotateZspeed':1,//旋转速度，【>0为顺时针，<0为逆时针】
					'rotateXangle':0,//旋转时候的X转角
					'rotateXspeed':0,//X轴旋转速度，【>0为顺时针，<0为逆时针】
					'rotateYangle':0,//旋转时候的Y转角
					'rotateYspeed':0,//Y轴旋转速度，【>0为顺时针，<0为逆时针】
					'timer':10,//ms
				},'animationType');
				return new function Kanimation(){
					this.opts = opts;
					opts.ths = this;
					this.doCircle = function(){
						//转圈圈的配置
						opts.focusElement.attr('data-animation-rotateZangle',opts.rotateZangle);
						var doThis = function(){
							var angle = opts.focusElement.attr('data-animation-rotateZangle');
							angle = parseFloat(angle);
							angle+=parseFloat(opts.rotateZspeed?opts.rotateZspeed:1);
							opts.focusElement.css('transform','rotate('+angle+'deg)');
							opts.focusElement.attr('data-animation-rotateZangle',angle);
							setTimeout(function(){
								doThis();
								},opts.timer);
						}
						doThis();
					};
					this.doRoute = function(code){
						//转圈圈的配置
						opts.focusElement.attr('data-animation-rotateZangle',opts.rotateZangle);
						var doThis = function(){
							var angle = opts.focusElement.attr('data-animation-rotateZangle');
							angle = parseFloat(angle);
							angle+=parseFloat(opts.rotateZspeed?opts.rotateZspeed:1);
							opts.focusElement.css('transform','rotate'+code+'('+angle+'deg)');
							opts.focusElement.attr('data-animation-rotateZangle',angle);
							setTimeout(function(){
								doThis();
								},opts.timer);
						}
						doThis();
					};
					this.doAnimation = function(){
						switch(opts.animationType){
							case 'circle':this.doCircle();break;
							case 'routeX':this.doRoute('X');break;
							case 'routeY':this.doRoute('Y');break;
							case 'routeZ':this.doRoute('Z');break;
						}
					};
					this.sync = function(){
						this.doAnimation();
					};
					this.sync();
				}
			},
			
			//在节点之后增加元素
			append:function(s){
				if(s.type&&(s.type=='KnodeList')){
					this.each(function(){
						var ths = this;
						k._e_e.selector(s).each(function(i,e){
							ths.appendChild(this);
						})
					});
					return this;
				}else if(Object.prototype.toString.call(s).indexOf('[object HTML')==0){
					this.each(function(){
						this.appendChild(s);
					});
					return this;
				}else if(Object.prototype.toString.call(s).indexOf('[object NodeList')==0){
					k._e_e.selector(this).each(function(){
						var ths = this;
						k._e_e.selector(s).each(function(){
							ths.appendChild(this);
						})	
					});
					return k._e_e.selector(this);
					
				}else{
					var h = k._f.parseHTML(s,true);
					k._e_e.selector(this).each(function(){
						var ths = this;
						k._e_e.selector(h).each(function(){
							ths.appendChild(this);
						})	
					});
					return k._e_e.selector(this);
				};
			},
			
			//属性相关信息
			attr:function(attrName,attrValue){
				if(!attrName)return null;
				return (attrValue==undefined)?this.getAttr(attrName):this.setAttr(attrName,attrValue);	
			},
			
			before:function(s){
				if(s==undefined){
					return k._e_e.selector(this.prev());
				}else{
					this.each(function(){
						if(s&&s.type&&s.type=='KnodeList'){
							var h = s.first(true);
						}else if(Object.prototype.toString.call(s).indexOf('[object HTML')==0){
							var h = s;
						}else{
							var h = k._f.parseHTML(s);
							h = h[0];
						};
						this.parentNode.insertBefore(h,this);
					});
				};
				return this;
			},
			
			change:function(a,useCapture){
				(a==undefined)
				?((function(e){
					e.each(function(){
						this.onchange&&this.onchange();	
					})
				})(this))
				:((function(e){
					e.each(function(i,ei){
						ei.onchange = a;
					})
				})(this));
				
			},
			
			//获取孩子列表
			//保证
			children:function(selecter,unselecter){
				//所有children列表
				//this.sync();
				var be = k.nodes.create('',this,true);
				var e =  k._e_e.selector(this.childs,this,true);
				if(selecter){
					var te = k._e_e.selector(selecter,this,true);
				}else{
					var te = e;
				};
				var ne = k._e_e.selector(unselecter);
				te.each(function(a,b){
					var init = true;
					ne.each(function(c,d){
						if(b==d){
							init = false;	
						}
					});
					if(init){
						be.push(b);
					};
				});
				be.sync();
				return be;
			},
			
			//点击事假相关操作
			//useCapture-使用捕获, 焦点捕获意味着是否唯一性，启动本函数之后事件只对当前的层生效
			click:function(a,useCapture){
				useCapture = useCapture ? 1: 0;
				var ret = true;
				(a==undefined)?((function(ele){
					ele.each(function(i,e){
						ret *= e.click(a);
					})
				})(this)):((function(ele){
					ele.each(function(i,e){
						(a===false)?((function(e1){
							e.onclick = function(ev){
								if(ev==null){return false;}
								if(ev.stopPropagation){
									ev.stopPropagation();
								}else if(window.ev) { 
									window.ev.cancelBubble = true;
								}
							}
						})(e)):e.onclick = a;
					})
				})(this));
			},
			clone:function(){
				var str = '';
				this.each(function(){
					str += this.outerHTML;
				});
				return k._e_e.selector(str);
			},
			//css
			css:function(a,b){
				return (typeof(a)=='object')
					?((function(ths){
						ths.each(function(){
							for(var i in a){
								this.style.setProperty(i,(typeof(a[i])=='function')?((a[i])(this)):a[i]);	
							}	
						});
						return ths;	
					})(this))
					:(b==undefined)
						?((function(e){
							return e.style.getPropertyValue(a);
							})(this.first(true)))
						:((function(ths){
							ths.each(function(){
								this.style.setProperty(a,(typeof(b)=='function')?((b)(this)):b);
							})
				})(this));	
			},
			//todo--doOn
			doOn:function(en){
				this.each(function(i,e){
					this['on'+en]&&this['on'+en]()
				})
			},
			
			empty:function(){
				this.each(function(i,e){
					this.innerHTML  = '';	
				});
				//重置内容信息
				this.sync();
				return this;
			},
			
			//待入文档
			eq:function(index){
				return k._e_e.selector(this.element[index]);
			},
			
			//元素查找
			find:function(selector){
				var ele = k.nodes.create(selector,this,true);
				ele.resetSelector();
				this.each(function(){
					if(this.nodeType==3){
						return;
					};
					if(this.nodeType==8){
						return;	
					};
					var nodes = this.querySelectorAll(ele.sSelector);
					for(var i =0;i<nodes.length;i++){
						ele.push(nodes[i]);
					}
				});
				if(ele.sClass=='first'){
					return ele.first();	
				}else if(ele.sClass=='last'){
					return ele.last();	
				};
				return k._e_e.selector(ele);
			},

			files:function(s){
				var files = k._f.files();
				this.each(function(){
					if(this.files){
						for(var i=0;i<this.files.length;i++){
							files.push(this.files[i]);	
						}	
					};	
				})
				return files;
			},
			//第一个元素
			first:function(isEle){
				var e = this.element[0]?this.element[0]:null;
				return isEle?e:k._e_e.selector(e);
			},
			
			//获取第一个孩子
			firstChild:function(isEle){
				var e = this.element[0]?this.element[0].firstElementChild:null;
				return isEle?e:k._e_e.selector(e);
			//最后一个元素
			},
			//显示全屏和取消全屏
			fullScreen:function(callback){
				var docElm = this.first(true);
				if (docElm.requestFullscreen) {
					docElm.requestFullscreen();
				}
				else if (docElm.msRequestFullscreen) {
					docElm.msRequestFullscreen();
				}
				else if (docElm.mozRequestFullScreen) {
					docElm.mozRequestFullScreen();
				}
				else if (docElm.webkitRequestFullScreen) {
					docElm.webkitRequestFullScreen();
				}
				document.onfullscreenchange = function(){
					callback&&callback();
				}
			},
			
			last:function(isEle){
				var l = this.length;
				var e = this.element[l-1]?this.element[l-1]:null;
				return isEle?e:k._e_e.selector(e);
			},
			
			//获取最后一个孩子
			lastChild:function(isEle){
				var e = this.element[0]?this.element[0].lastElementChild:null;
				return isEle?e:k._e_e.selector(e);
			},
			
			focus:function(fc,useCapture){
				return fc
					?((function(ths){
						return (typeof(fc)=='function')?((function(){
							ths.addEventListener("focus",fc,useCapture);
							return k._e_e.selector(ths);
						})()):k._e_e.selector(ths);
					})(this.first(true)))
					:((function(ths){
						ths.focus();
						return k._e_e.selector(ths);
					})(this.first(true)))
			},
			
			
			getAttr:function(attributeName){
				var e = this.first(true);
				return e?e.getAttribute(attributeName):null;
			},
			
			getFormdata:function(){
				try{
					var ths = this;
					this.form = this.first(true);
					this.getType = function(ele){
						var tp = k._e_e.selector(ele).attr('type');
						if(!tp){ tp = k._e_e.selector(ele).attr('data-type')}
						tp = k._f.strtolower(tp);
						if(!tp){tp = '';}
						return tp;
					}
					this.formData = {};
					this.setData = function(nm,vl){
						var type = Object.prototype.toString.call(this.formData[nm])
						if(type=='[object Array]')

						{
							this.formData[nm].push(vl);	
						}else{

							this.formData[nm] = vl;	
						}	
					}
					k._e_e.selector(this).find("[name]").each(function(index, element) {
						var tp = ths.getType(this);
						var nm = k._e_e.selector(element).attr('name');
						var hnm = /^([0-9a-zA-Z\_\[\]]+)(\[\])$/g.exec(nm);
						if(hnm){
							nm = hnm[1];
							if(!ths.formData[nm])ths.formData[nm] = [];
						}
						switch(tp){
							case 'checkbox':
								if(k._e_e.selector(this).prop('checked')){
									var vl = k._e_e.selector(element).val();
									ths.setData(nm,vl);
								}
							break;
							case 'radio':
								if(k._e_e.selector(this).prop('checked')){
									var vl = k._e_e.selector(element).val();
									ths.setData(nm,vl);
								}
							break;
							case 'file':
								var sty = k._e_e.selector(element).getAttr('data-type');
								var f = k._e_e.selector(element).files();
								if(sty=='file'){
									var vl = k._e_e.selector(element).files(0);	
								}else if(sty=='files'){
									var vl = k._e_e.selector(element).files();	
								}else{
									if(f.length>1){
										var vl = k._e_e.selector(element).files();	
									}else{
										var vl = k._e_e.selector(element).files(0);	
									}
								}
								ths.setData(nm,vl);
							break;
							default:
								var vl = k._e_e.selector(element).val();
								ths.setData(nm,vl);
						}
					})
					return this.formData;
				}catch(err){
					console.error(err);
					return {};	
				}
			},
			
			getProp:function(a){
				return this.first(true)[a];
			},
			
			hasAttr:function(abn){
				var e = this.first(true);
				return e?e.hasAttribute(abn):null;
			},
			
			hasClass:function(className){
				var a = false;
				var e = this.first(true);
				if(!e){return false;}
				for(var i = 0;i<e.classList.length;i++){
					if(e.classList[i]==className){
						a = true;
					}
				}
				return a;
			},
			
			//高度
			height:function(p){
				if(this.length==0){return 0;}
				return (p==undefined)?
				((function(e){
					return e.offsetHeight})(this.first(true)))
				:((function(ths){
					ths.each(function(){
						this.style.height = parseFloat(p)+"px";	
					});
					})(this));
			},
			
			//外部高度
			outerHeight:function(){
				if(this.length==0){return 0;}
				console.log(this);	
			},
			
			//获取节点包含节点所有的内部节点所有信息
			//是否为dom元素节点
			outerHtml:function(){
				return this.first(true).outerHTML;
			},
			
			hide:function(antype,antime){ return this.css('display','none')},
			//html
			html:function(opts){
				if(this.length==0){return null;}
				return (opts==undefined)
					?((function(e){return e?e.innerHTML:'';})(this.first(true)))
					:((function(ths){
						ths.empty();
						ths.each(function(){
							if(opts.type&&opts.type=='KnodeList'){
								var sths = k._e_e.selector(this);
								sths.innerHTML = '';
								opts.each(function(){
									sths?sths.append(this):null;
								})
							}else{
								this?this.innerHTML=opts:null;
							}
						})
					})(this))
			},
			
			//针对form表单的数据验证
			isValid:function(){
				var ths = this;
				ths.isValid = true;
				this.form = this.first(true);
				if(this.form.tagName!='FORM'){return false;}
				this.getType = function(ele){
					var tp = k._e_e.selector(ele).attr('type');
					if(!tp){ tp = k._e_e.selector(ele).attr('data-type')}
					tp = k._f.strtolower(tp);
					if(!tp){tp = '';}
					return tp;
				}
				
				this.find("[name]").each(function(index, element) {
					var tp = ths.getType(this);
					var vl = k._e_e.selector(this).val();
					switch(tp){
						case 'require':
							if(vl.length<1){
								k._e_e.selector(this).focus();
								ths.isValid = false;
								return false;
							}
						break;
						default:;
					}
				})
				return ths.isValid;
			},
			
			//todo--moveToNext
			moveToNext:function()
			{
				var next = this.next().next();
				if(next.first(true)){
					this.parent().first(true).insertBefore(this.first(true),next.first(true));
				}else{
					this.parent().append(this.first(true));	
				}
			},
			//元素向上移动一个单位
			//todo--moveToPrev
			moveToPrev:function()
			{
				var prev = this.prev();
				if(prev.first(true)){
					this.parent().first(true).insertBefore(this.first(true),prev.first(true));	
				}else{
					this.parent().prepend(this.first(true));		
				}
			},
			//向下移动一个单位
			next:function()
			{
				var e = this.first(true);
				return k._e_e.selector(e?e.nextElementSibling:null);
			},
			
			on:function(code,evt){
				this.each(function(i,e){
					(evt==undefined)?(k._e_e.selector(this).doOn(code)):((function(ths){
						var c = 'on'+ code;
						ths[c] = evt;
						})(this));
				})
			},
			
			parent:function(isEle){
				var ele = k._e_e.selector(this._parent);
				return isEle?ele.first(true):ele;
			},
			
			parents:function(selector){
				var l = k._e_e.selector(selector);
				if(l.length==0){ return null;}//如果元素不存在，则返回null
				var p = this.parent();
				if(p.length==0){ return null;}
				var n = k._e_e.selector('');
				l.each(function(i,e){
					if(e==p.first(true)){
						n.push(e);
					}
				})
				n.sync();
				if(n.length==0){
					return p.parents(selector);
				}
				return n;
			},
			
			//这种是自动创建插件并返回的，会默认将元素绑定到插件的boxElement上
			plugIn:function(plugName,plugOpts){
				if(k._f.plugIn[plugName]){
					plugOpts = k._f.optionsInput(plugOpts,{
						boxElement:this.first(true),
						timestame: Math.ceil((new Date()).getTime() / 1000),
					},'timestame');
					return new k._f.plugIn[plugName](plugOpts);
				}else{
					k.debug('扩展功能['+plugName+']不可用','plugIn');	
				}
			},
			
			prepend:function(s){
				if(s==undefined){
					return k._e_e.selector(this.prev());
				}else{
					this.each(function(){
						//循环当前信息
						//判定当前元素是否为第一个元素
						if(s&&s.type&&s.type=='KnodeList'){
							var h = s.first(true);
						}else if(Object.prototype.toString.call(s).indexOf('[object HTML')==0){
							var h = s;
						}else{
							//string
							var h = k._f.parseHTML(s);
							h = h[0];
						}
						
						//判断当前是否有元素信息，话说没有元素信息的话，这里应该进不来吧，判断是否you孩子元素
						//如果没有的话，同append
						if(this.childNodes.length){
							//这个是you孩子元素的	
							//拉去第一个孩子
							this.insertBefore(h,this.firstChild);
						}else{
							//这个没有孩子啊，没有孩子的话，直接增加一个孩子就可以了
							this.appendChild(h);
						}
					});
				}
				//返回当前对象信息
				return this;
			},
			prev:function(){
				var e = this.first(true);
				return k._e_e.selector(e?e.previousElementSibling:null);
			},
			prop:function(ppn,ppv){
				if(!ppn)return null;
				return (ppv===undefined)?this.getProp(ppn):this.setProp(ppn,ppv);
			},
			//节点准备ok
			ready:function(callback){
				if(callback==undefined){k.ready.callback();}
				k.ready.push(callback);
				var elenum = this.element.length;
				if(elenum<1){callback&&callback();return true;}
				var hasnum = 0;
				this.each(function(i,e){
					e.onreadystatechange = function(){
						if(e.readyState=='complete')hasnum++;
						if(hasnum>=elenum){
							k.ready.callback();
						}
					}	
				})
				return true;
			},
			
			//执行删除节点
			remove:function(){
				if(this.element.length>0){
					this.each(function(){
						var p;
						(p = this.parentNode)&&(p.removeChild(this));
					})
				}
			},
			
			removeClass:function(className){
				this.each(function(i,e){
					var c = '';
					if(e.classList&&e.classList.length>0){
						for(var j=0;j<e.classList.length;j++){
							var a = e.classList[j];
							if(a!=className){
								if(c){
									c+=' '+a;	
								}else{
									c+=a;
								}
							}
						}
						e.className = c;
					}
				})
				return this;
			},
			removeChild:function(){},
			
			removeAttr:function(attrName){
				this.each(function(i,e){
					e.removeAttribute(attrName);
				})
				return this;	
			},
			scrollToBottom:function(){
				this.each(function(){
					//需要优化有滑动效果
					//top = parseInt(top);
					//if(!top){
					   //top = 0;
					//}
					//document.getElementById(id).scrollIntoView({ behavior: 'smooth',top:top})
					this.scrollTop = this.scrollHeight;
				})
			},
			setAttr:function(attributeName,attributeValue){
				this.each(function(i,e){
					e.setAttribute(attributeName,attributeValue);	
				})
				return this;
			},
			
			//元素选择器，element,a常规选择器。b.父级返回元素，c是否只查找b的子元素
			//a：为带查找的选择器集合
			//b:限定待查找范围
			//c:限定只查找返回的子集合，不包含自己
			selector:function(a,b,c){
				if(a&&a.type=='KnodeList'){
					//判定为已经序列化的直接返回，不再序列化
					//这个时候b,c都没用了呢
					a.sync();
					return a;
				}
				//初始化一个元素对象
				var doc = k.nodes.create(a,b,c);
				//创建一个基础的create
				if(doc.sType =='[object String]'){
					//字符串类型的类型
					doc.resetSelector();
					if(doc.sSelector){
						var eles = doc.parent(true).querySelectorAll(doc.sSelector);
						for(var i =0 ;i < eles.length ; i++){
							doc.push(eles[i]);	
						}
					}
				}else if(doc.sType == '[object HTMLCollection]'){
					for(var i=0;i<doc.selector.length;i++){
						doc.push(doc.selector[i]);
					}
				}else if(doc.sType == '[object NodeList]'){
					for(var i=0;i<doc.selector.length;i++){
						doc.push(doc.selector[i]);
					}
				}else if(doc.sType == '[object Array]'){
					for(var i=0;i<doc.selector.length;i++){
						doc.push(doc.selector[i]);
					}
				}else if(/^\[object\sHTML/.test(doc.sType)){
					//这里是元素标签信息，会返回标签相关信息
					doc.push(doc.selector);
				}
				doc.sync();
				return doc;
			},
			
			setProp:function(a,b){
				this.each(function(i,e){ e[a] = Boolean(b);});return this;
			},
			
			show:function(antype,antime){
				antime = antime?antime:500;
				switch(antype){
					default:this.css('display','block');
				}
			},
			
			siblings:function(selecter){
				return this.parent().children(selecter,this.first(true));
			},
			
			//isConstructer
			touch:function(){
				var ths = this;
				var touch = new function Ktoucher(){
					this.touchStart = null;
					this.touchMove = null;
					this.touchEnd = null;
					this.onMovePoint = 64;//移动计算的距离长度
					this.onLongPoint = 1000;//长按的时间尺度
					//标记长按的开始时间节点，在过程中保持不动才算是长按，如果移动则视为移动
					this.isTouchMove = false;//是否为移动类型
					this.isTouchLong = false;//是否为长按
					this.tmpTouchLongtimer = 0;//长按的接触时间节点
					this.onMoveToLeft = null;//向左移动
					this.onMoveToRight = null;//向右移动
					this.onTouchFocus = null;//开始接触
					this.onTouchBlur = null;//停止接触触发
					this.onTouchLong = null;//长按返回方法
					this.doMoveLength = function(){
						var sx = this.touchStart.touches[0].screenX;
						var sy = this.touchStart.touches[0].screenY;
						var ex = this.touchEnd.changedTouches[0].screenX;
						var ey = this.touchEnd.changedTouches[0].screenY;
						if(sx - ex >this.onMovePoint){
							this.onMoveToLeft&&this.onMoveToLeft(this);	
						}
						if(ex-sx>this.onMovePoint){
							this.onMoveToRight&&this.onMoveToRight(this);	
						}
					}
					//触发长按判定
					this.doLongPress = function(){
						if(!this.isTouchMove){
							//触发长按标识
							this.onTouchLong&&this.onTouchLong();	
						}
					};
					var that = this;
					k._e_e.selector(ths).on('touchStart',function(rs){
						that.touchStart = rs;
						that.touchMove = null;
						that.touchEnd = null;
						that.isTouchMove = false;
						that.isTouchLong = false;
						that.tmpTouchLongtimer = setTimeout(function(){
								//如果这个期间没有发生移动，则触发长按
								that.doLongPress();
							},that.onLongPoint);
					});
					k._e_e.selector(ths).on('touchMove',function(rs){
						that.touchMove = rs;
						that.isTouchMove = true;
					});
					k._e_e.selector(ths).on('touchEnd',function(rs){
						that.touchEnd = rs;
						//执行长按的倒计时的释放
						if(that.tmpTouchLongtimer){
							clearTimeout(that.tmpTouchLongtimer);
							}
							
						that.doMoveLength();
					});
				};
				return touch;	
			},
			
			//针对表单的提交
			submit:function(func){
				return (typeof(func)=='function')?((
					function(ths){
						ths.each(function(){
							this.onsubmit = function(){
								this._cbk = func;
								this._cbk();
								return false;
							}
						});
					}
				)(this)):((function(ths){
					ths.each(function(){
						this.submit();
						})
					})(this));
			},
			
			//text
			text:function(text){
				if(text!=undefined){
					this.each(function(i,e){
						e.textContent = text;	
					})
					return this;
				}else{
					return this.first(true)?this.first(true).textContent:null;
				}
			},
			
			//val
			val:function(v){ 
				return (v==undefined)?((
					function(ths){
						return ths.value;
					}
				)(this.first(true))):((
					function(ths){
						ths.each(function(){
							this.value = v;	
							this.oninput&&this.oninput();
						})
						return ths;	
					}
				)(this))
			},
			
			//width
			width:function(p){
				return (p==undefined)?
				((function(e){
					return e.offsetWidth})(this.first(true)))
				:((function(e){
					e.each(function(){
						this.style.width = parseFloat(p)+"px";	
					})
				})(this));
			},
		},
		
				
		//配置dom节点列表的相关操作
		//nodes.create,为创建新基础节点的相关方式方法
		nodes:{
			
			selector:'',
			_parent:null,
			justChild:false,
			//构建对象方法
			//a:selector
			//b:parent
			//c:justChild
			create:function(a,b,c){
				var KnodeList = function(){
					k.nodes.__proto__ = k._e_e;
					this.__proto__ = k.nodes;
					this.length = 0;
					this.selector = a;
					this.sSelector = '';
					this.sClass = '';
					this.sType = Object.prototype.toString.call(a);
					this._parent = b?b:document;
					this.childs = [];
					this.justChild = c?c:0;
					this.element = [];
					this.type='KnodeList';
				}
				var element =  new KnodeList();	
				element.sync();
				return element;
			},
			
			//重置选择器基础参数信息
			resetSelector:function(){
				//var str = '\u3002\uff1f\uff01\uff0c\u3001\uff1b\uff1a\u201c\u201d\u2018\u2019\uff08\uff09\u300a\u300b\u3008\u3009\u3010\u3011\u300e\u300f\u300c\u300d\ufe43\ufe44\u3014\u3015\u2026\u2014\uff5e\ufe4f\uffe5';
				//var ex = /^([0-9a-zA-Z\_\-\[\]\>\s\.\#\"\=\u4e00-\u9fa5]*)(:)?([0-9a-zA-Z\_\-\[\]\(\)\>\s\.\#]*)$/g.exec(this.selector);
				//var ex = /^(\S*)(:)([0-9a-zA-Z\_\-\[\]\(\)\>\s\.\#]*)$/g.exec(this.selector);
				//判定是否为一个标签类型，如果为标签类型则视为非选择器
				var isslt = /\<.*\>/.exec(this.selector);
				if(isslt){
					//这个判定为非选择器
					//这里判定为非选择器，则可能是代码片段
					this.selector = k._f.parseHTML(this.selector);
					this.sType = Object.prototype.toString.call(this.selector);
					for(var i=0;i<this.selector.length;i++){
						this.push(this.selector[i]);
					}
					
				}else{
					//这个判定为选择器	
					//判定是否有伪类选择器
					var ex = /^(\S*)(:)([0-9a-zA-Z\_\-\[\]\(\)\>\s\.\#]*)$/g.exec(this.selector);
					if(ex){
						this.sSelector = ex[1];
						this.sClass = ex[3];
					}else{
						//这是没有伪类的情况
						this.sSelector = this.selector;
					}
					
				}
			},
			
			//数据循环
			each:function(_cbk){
				for(var i=0;i<this.element.length;i++){
					this.element[i]._cbk = _cbk;
					this.element[i]._cbk(i,this.element[i]);
				}
				return true;
			},
			

			//将数据写入对象中
			push:function(ele){
				this.element.push(ele);
			},
			
			//同步对象相关数据信息的方法
			sync:function(){
				var ths = this;
				//重置孩子信息跟重置parent信息
				//清空孩子列表
				
				this.each(function(){
					ths.childs = [];
					if(this.children){
						for(var i=0;i<this.children.length;i++){
							ths.childs.push(this.children[i]);
						}	
					}
					ths._parent = this.parentElement;
				})
				//重置长度单位信息
				this.length = this.element.length;	
			},
		},
		
		
		//方式方法列表
		_f:{
			
			ID:'_'+Math.ceil(Math.random() * 100000),
			
			ajax:function(opts){
				return new function kajax(){
					this.opts = k._f.optionsInput(opts,{
						url:'',
						type:'get',
						data:{},
						dataType:'',
						success:function(){},
						error:function(){},
						isSec:false,//是否为分段请求
						//多请求判定函数
						secCheck:function(rs,yes_back,err_back){},
					});
					this.opts.method = this.opts.type;
					this.opts.action = this.opts.url;
					this.proxy = k._f.proxy(this.opts);
					this.proxy.send();
				}
			},
			
			//alert
			alert:function(opts){
				return new function kalert(){
					this.opts = k._f.optionsInput(opts,{
						tips:'',
						width:((function(){
							if(k._f.isMobile){
								return '80%';
							}else{
								return '400px';
								}
							
							})()),
						autoCreate:false,
						text:'',
						class:'card-alert',
						sureText:'关闭',//确定按钮的内容
						sureStyle:'margin: 5px;vertical-align: bottom;box-sizing: border-box;background-color: unset;border: 1px solid #dedede;border-radius: 5px;padding: 5px 10px;opacity: 0.95;cursor: pointer;',//确定按钮的样式
						cancel:function(){return true;},
					});
					this.opts.content = '<div style="margin:15px;">'+(this.opts.text?this.opts.text:"")+'</div>';
					this.card = new k._f.card(this.opts);
					this.card.beforeCreate = function(){
						var ths = this;
						var btn = k._e_e.selector('<button type="button" style="'+this.opts.sureStyle+'">'+this.opts.sureText+'</button>');
						btn.click(function(){
							ths.opts.cancel();
							ths.format.closeIcon.click();	
						})
						var box = k._e_e.selector('<div style="text-align:center;margin: 10px;"></div>');
						box.append(btn);
						this.format.foot.append(box);
					}
					this.card.create();
				}	
			},
			
			//读取和获取配置
			config:function(cname,cvalue){
				if(cname){
					return ((cvalue==undefined)||(cvalue==null))? k._config[cname]:(k._config[cname] = cvalue) ;
				}else{
					return '';	
				}
			},
			
			//base64编码
			base64encode:function(stream){
				return window.btoa(stream);	
			},
			
			//base64解码
			base64decode:function(stream){
				return window.atob(stream);	
			},
			
			//信息确定框
			confirm:function(opts){
				return new function kconfirm(){
					this.opts = k._f.optionsInput(opts,{
						tips:'',
						width:((function(){
							if(k._f.isMobile){
								return '80%';
							}else{
								return '400px';
								}
							
							})()),
						autoCreate:false,
						text:'',
						class:'card-confirm',
						sureText:'确定',//确定按钮的内容
						sureStyle:'margin: 5px;vertical-align: bottom;box-sizing: border-box;background-color: unset;border: 1px solid #dedede;border-radius: 5px;padding: 5px 10px;opacity: 0.95;cursor: pointer;',//确定按钮的样式
						cancelText:'取消',//确定按钮的内容
						cancelStyle:'margin: 5px;vertical-align: bottom;box-sizing: border-box;background-color: unset;border: 1px solid #dedede;border-radius: 5px;padding: 5px 10px;opacity: 0.95;cursor: pointer;',//确定按钮的样式
						sure:function(){return true;},
						cancel:function(){return true;},
					});
					this.opts.content = '<div style="margin:15px;">'+(this.opts.text?this.opts.text:"")+'</div>';
					this.card = new k._f.card(this.opts);
					this.card.beforeCreate = function(){
						var ths = this;
						var btn = k._e_e.selector('<button type="button" style="'+this.opts.sureStyle+'">'+this.opts.sureText+'</button>');
						var btn2 = k._e_e.selector('<button type="button" style="'+this.opts.cancelStyle+'">'+this.opts.cancelText+'</button>');
						btn.click(function(){
							ths.opts.sure();
							ths.format.closeIcon.click();	
						})
						btn2.click(function(){
							ths.opts.cancel();
							ths.format.closeIcon.click();	
						})
						var box = k._e_e.selector('<div style="text-align:center;margin: 9px;"></div>');
						box.append(btn);
						box.append(btn2);
						this.format.foot.append(box);
					}
					this.card.create();
				}		
			},
			
			//日期基础
			date:function(options){
				return new function Kdate(){
					var opts = this.opts = k._f.optionsInput(options,{
						format:'YYYY-mm-dd HH:ii:ss',//输出格式	
						//时间部分
						timeStamp:(new Date()).getTime() / 1000,
						stream:'',//最后一次正确输出
					},'timeStamp');
					opts.ths = this;
					if(this.opts.timeStamp){
						this.opts.timeStamp = parseInt(this.opts.timeStamp);
						this.date = new Date(this.opts.timeStamp * 1000);	
					}else{
						this.date = new Date();		
					}
					//获取年
					this.getYear = function(){ return this.date.getFullYear();};
					//获取月
					this.getMonth = function(){ return this.date.getMonth()+1;};
					//获取日
					this.getDate = function(){ return this.date.getDate();};
					//获取周几
					this.getDay = function(){ return this.date.getDay();};
					//获取小时
					this.getHours = function(){ return this.date.getHours();};
					//获取分钟
					this.getMinutes = function(){ return this.date.getMinutes();};
					//获取秒
					this.getSeconds = function(){ return this.date.getSeconds();};
					//获取时间戳
					this.getTime = function(){ return this.date.getTime();};
					//获取本月的天数
					this.getMonthDatenum = function(){
						var date = new Date(this.getYear(),this.getMonth());
						date.setTime(date.getTime() - 86400 * 1000);
						return date.getDate();
					};
					//获取年
					this.setYear = function(Y){ this.date.setFullYear(Y);return this;};
					//获取月
					this.setMonth = function(m){ this.date.setMonth(parseInt(m)-1);return this;};
					//获取日
					this.setDate = function(d){ this.date.setDate(d);return this;};
					//获取小时
					this.setHours = function(H){ this.date.setHours(H);return this;};
					//获取分钟
					this.setMinutes = function(m){ this.date.setMinutes(m);return this;};
					//获取秒
					this.setSeconds = function(s){ this.date.setSeconds(s);return this;};
					//设置时间戳
					this.setTime = function(t){ 
						this.date.setTime(parseFloat(t) * 1000);
						return this;
					};
					//设置向后时间戳
					this.next = function(nt){ 
						this.date.setTime(this.date.getTime() + parseFloat(nt) * 1000);
						return this;
					};
					//设置向前时间戳
					this.prev = function(pv){ 
						this.date.setTime(this.date.getTime() - parseFloat(pv) * 1000);
						return this;
					};
					//格式化字符串
					this.format = function(format){ this.opts.format = format;return this;};
					//输出
					this.output = function(format){
						if(format){ this.opts.stream = format;}else{ this.opts.stream = this.opts.format;}
						this.opts.stream = this.opts.stream.replace(/Y{1,4}/g,function(rs){
							return opts.ths.getYear().toString().substring(4-rs.length,4);
						});
						this.opts.stream = this.opts.stream.replace(/m{1,2}/g,function(rs){
							return k._f.strspad(opts.ths.getMonth(),'0',2);
						});
						this.opts.stream = this.opts.stream.replace(/d{1,2}/g,function(rs){
							return k._f.strspad(opts.ths.getDate(),'0',2);
						});
						this.opts.stream = this.opts.stream.replace(/H{1,2}/g,function(rs){
							return k._f.strspad(opts.ths.getHours(),'0',2);
						});
						this.opts.stream = this.opts.stream.replace(/i{1,2}/g,function(rs){
							return k._f.strspad(opts.ths.getMinutes(),'0',2);
						});
						this.opts.stream = this.opts.stream.replace(/s{1,2}/g,function(rs){
							return k._f.strspad(opts.ths.getSeconds(),'0',2);
						});
						return this.opts.stream;
					};
					
				}	
			},
			
			debug:function(opts){
				var str = '<section style="position: relative;z-index: 519101;">';
				var debugObject = function(object,index){
					str += '<details>';
					str += '<summary>[Object:'+index+']</summary>';
					str += '<div>';
					for(var i in object){
						doDebug(object[i],i);
					}
					str += '</div>';
					str += '</details>';
				}
				var debugArray = function(object,index){
					str += '<details>';
					str += '<summary>[Array:'+index+']</summary>';
					str += '<div>';
					for(var i in object){
						doDebug(object[i],i);
					}
					str += '</div>';
					str += '</details>';
				}
				var doDebug = function (opts,index){
					//todo--debug
					str += '<div style="margin-left: 15px;">';
					var type = Object.prototype.toString.call(opts,index);
					
					switch(type){
						case '[object Object]':debugObject(opts,index);break;
						case '[object Array]':debugArray(opts,index);break;
						case '[object Function]':
							str += index + ' : [Function][]';
							break;
						case '[object String]':
							str += index + ' : [String]"'+opts+'"';
							break;
						case '[object Number]':
							str += index + ' : [Number]'+opts;
							break;
						case '[object HTMLDocument]':
							str += index + ' : [HTMLDocument]'+opts;
							break;
						case '[object Boolean]':
							str += index + ' : [Boolean]'+(opts?'true':'false');
							break;
						case '[object Null]':
							str += index + ' : [Null]'+'null';
							break;
						case '[object Undefined]':
							str += index + ' : [Undefined]'+'Undefined';
							break;
						default:console.log(type);
					}
					str += '</div>';
					return str;
				}
				doDebug(opts,'main');
				str += '</section>';
				k._e_e.selector('body').append(str);
			},
			
			//constructer
			//作为基础对象，是不包含options输入的
			file:function(file){
				k.debug('文件初始化','file');
				return new function Kfile(){
					this.onprogress = null,//当前文件上传进度提示
					this.onsuccess = null,//上传成功执行
					this.onerror = null,//上传失败执行
					this.oncompress = null,//文件片段压缩进度信息，当然是当前片段的部分
					
					this.secMaxsize = 524288;//最大的大小，如果操作需要切片
					this.secSize = 0;//是否切片，非0则视为切片,非切片的时候需要保证文件完整性
					this.seclist = [];//放置扩展切片的地方
					this.secMaxnum = 0;//最大切片数量
					this.secMaxlev = 0;//最大切片数量级
					this.uploadStatus = 0;//0:等待上传，1：上传成功，2：上传中
					this.pointer = 0;//这个是文件指针
					this.fileReader = new FileReader();
					this.tryMaxnum = 5;//自动重试次数
					this.file = file;
					this.uploadName = 'filename';
					this.isUpload = 0;//上传状态
					this.isSec = 0;//切片状态
					
					
					//
					this.onUploadProgress = null,
					//当前片段上传触发
					this.onSecProgress = null,
					
					this.err = null;//异常结果信息
					
					
					
					
					//检测切片是否完成或者是否结尾
					this.secCheck = function(rs){return true;}
					
					this.md5 = '';//这个为扩展md5方法，需要用于验证数据完整性
					this.def_updata = {};//默认需要上传的数据们
					//默认的一些变量都放这里面吧，不重复就行
					this.tmp = {
						
					};
					
					this.sendIndex = 0;
					this.uploadSepeed = null;//上传进度显示方法
					var ths = this;
					this.getTmpurl = function(){
						return window.URL.createObjectURL(this.file);	
					};
					
					//尝试根据创建元素信息来创建文件信息
					//创建成功返回，和创建失败返回
					this.createBynone = function(_scall,_ecall){
						k.debug('点击尝试创建文件对象','file->createBynone');
						var ths = this;
						var ele =  k._e_e.selector('<input hidden="" type="file" />');
						k._e_e.selector('body').append(ele);
						ele.change(function(){
							k.debug('点击尝试创建文件对象返回','file->createBynone');
							ths.file = k._e_e.selector(this).files().item(0).file;
							k._e_e.selector(ele).remove();
							ths._callback = _scall;
							ths._callback&&ths._callback();
						})
						ele.click();
					};
					
					//获取文件名
					this.getFilename = function(){
						return this.file.name;
					};
					
					//获取文件大小
					this.getFilesize = function(isByte){
						return isByte?this.file.size:k._f.filebyte2size(this.file.size);
					};
					
					//获取一个待上传的片段
					this.getSecfileWithnoupload = function(){
						for(var i=0;i<this.seclist.length;i++){
							if(this.seclist[i].uploadStatus==0){
								return this.seclist[i];
							}	
						}
						return null;
					}
					
					
					//根据当前信息创建一个切片
					//2022-3-11
					this.doCreateSecBynow = function(callback){
						var ths = this;
						var data = {};
						data.secSize = this.secSize;//每个切片大小
						data.pointer = this.pointer;//当前文件指针开始位置
						//切到当前文件
						var blob = this.file.slice(ths.pointer,ths.secSize+ths.pointer,ths.file.type);
						data['blob'] = blob;
						//这里返回关于当前切片的一些基本信息，这是压缩的
						//获取到本切片信息的具体内容取出来，为了md5
						this.fileReader.onloadend = function(){
							//获取文件对象信息
							var file = {};
							var conts = btoa(this.result);
							file.binary = new File([conts],ths.file.name,{type:ths.file.type});
							file.md5 = k._f.md5(conts);
							file.sec_id = k._f.strspad(ths.pointer,0,ths.secMaxlev);
							file.uploadStatus = 0;//0:等待上传，1：上传成功，2：上传中
							file.tryUploadnum = ths.tryMaxnum;//失败尝试重新请求的最大值
							file.tryUploadnow = 0;//失败尝试请求的数量
							ths.seclist.push(file);//将切片加入到当前列表中
							data.file = file;
							ths.oncompress&&ths.oncompress(k.error(0,'ok',data));//片段压缩反馈
							ths.pointer += ths.secSize;//将当前指针向后移动一个片段长度
							callback&&callback();
							return;
						}
						this.fileReader.readAsBinaryString(blob);//将数据绑定到文件阅读器中，为了将数据取出来
					};
					
					//当前文件获取一个切片并返回，如果超过位置则返回null,成功返回
					this.doCreateSec = function(callback){
						var ths = this;
						//执行切片的具体步骤信息
						if(this.pointer>=this.secMaxnum){
							k.debug('切片完成，需要执行监听方法的话，在这里绑定','file');
							callback&&callback();	
						}else{
							//没有执行完毕，继续执行
							this.doCreateSecBynow(function(){
								//这个切片添加成功，执行下一个切片	
								ths.doCreateSec(callback);
							});
						}
					}
					
					//执行切片文件部分
					this.doSec = function(callback){
						if(!this.file){
							k._f.error('文件信息不存在，切片自动退出');
							return callback&&callback();
						}
						if(this.secSize){
							//初始化切片所有信息
							//获取当前文件信息
							this.seclist = [];
							this.pointer = 0;//文件指针归到起始位置
							this.secMaxnum = 0;//最大切片数量
							this.secMaxlev = 0;//最大切片数量级
							
							//获取最大切片数量
							this.secMaxnum = Math.ceil(this.file.size / this.secSize);
							//获取最大切片量级
							this.secMaxlev = Object(this.secMaxnum).toString().length;
							//执行切片的具体操作
							this.doCreateSec(function(){
								k.debug('切片完成，等待下一步处理','file');
								callback&&callback();
							});
						}else{
							k.debug('不需要切片');
							return callback&&callback();	
						}
					};
					
					//文件模块上传文件部分文件一次性完成发送数据方法
					this.upload_sendfull = function(){
						var ths = this;
						k.debug('upload_sendfull','file');
						this.proxy.emptyDatas();//清空当前文件
						this.proxy.setData('upload_type','file');//配置上传数据类型
						this.proxy.setData(this.uploadName,this.file);
						this.proxy.setDatas(this.def_updata);//写入默认数据列表信息
						//成功执行方法
						this.proxy.success = function(rs){
							ths.isUpload = 1;//文件上传成功
							ths.onsuccess&&ths.onsuccess(rs);
						}
						//失败执行方法
						this.proxy.error = function(rs){
							ths.isUpload = 2;//文件上传失败
							ths.onerror&&ths.onerror(rs);	
						}
						this.proxy.send();
					}
					
					//文件模块上传文件上传文件片段信息
					this.upload_sendsec = function(callback){
						var ths = this;
						//发送一个片段的实际操作方法
						var send = function (){
							var sec = ths.getSecfileWithnoupload();
							if(sec){
								//片段信息存在，直接做执行的部分	
								k.debug('upload_sendsec','sec');
								ths.proxy.emptyDatas();//清空当前文件
								ths.proxy.setData('upload_type','sec');//配置上传数据类型
								ths.proxy.setData(ths.uploadName,sec.binary);
								ths.proxy.setData('md5',sec.md5);//配置上传数据类型
								ths.proxy.setDatas(ths.def_updata);//写入默认数据列表信息
								ths.proxy.success = function(rs){
									sec.uploadStatus = 1;
									//执行成功继续执行下一个片段信息
									send();
								}
								ths.proxy.error = function(rs){
									if(sec.tryUploadnow>=sec.tryUploadnum){
										//上传次数已经超过限制啦，这个直接判定为上传失败
										sec.uploadStatus = 2;	
									}else{
										//自动重试
										sec.uploadStatus = 0;
										sec.tryUploadnow++;
									}
									send();
								}
								ths.proxy.send();
							}else{
								//片段信息，已经不存在了，就当做已经发送完成
								//片段发送完毕，也就是上传成功了，该如何操作呢
								//当然是发送成功啦
								
								callback&&callback();
							}
						}
						send();
						
					}
					
					//代理部分
					this.proxy = k._f.proxy({
						dataType:'json',
						method:'post',
						data:{},
						//进度条监听信息
						progress:function(cfg){
							ths.onprogress&&ths.onprogress(cfg);//onProgress
						},
					});
					
					//文件上传部分
					this.upload = function(url){
						var ths = this;
						this.proxy.setUrl(url);
						//根据之前的信息判定是否需要
						if(this.secSize){
							k.debug('文件上传被执行，需要分片','file.upload()');
							//执行切片操作
							this.doSec(function(){
								ths.upload_sendsec(function(){
									//发送完成
									k.debug('上传完成','file');
									ths.isUpload = 1;//文件上传成功
									ths.onsuccess&&ths.onsuccess(ths);
								});
							});
						}else{
							k.debug('文件上传被执行，不需要分片','file.upload()');
							this.upload_sendfull();
						}
					}
				}	
			},
			
			files:function(){
				k.debug('尝试创建多文件信息');
				return new function Kfilelist(){
					//尝试根据创建元素信息来创建文件信息
					var ths = this;
					this.createBynone = function(callback){
						var ths = this;
						var ele =  k._e_e.selector('<input multiple="multiple" hidden="" type="file" />');
						k._e_e.selector('body').append(ele);
						ele.change(function(){
							for(var i=0;i<this.files.length;i++){
								ths.files.push(k._f.file(this.files.item(i)));	
							}
							k._e_e.selector(ele).remove();
							ths.callback = callback;
							ths.callback&&ths.callback();
						})
						ele.click();
					};
					this.files = [];
					this.push = function(file){
						 this.files.push(k._f.file(file));	
					}
					this.each = function(func){
						for(var i=0;i<this.files.length;i++){
							this.tmpFile = func;
							this.tmpFile(i,this.files[i]);	
						}	
					}
					this.item = function(index){
						return this.files[index]?this.files[index]:k._f.file();	
					}
				}	
			},
			
			//使用扩展引入MD5
			//借用的别人家的，不是自己写的
			md5:function(a){
				function b(a,b){var c=(65535&a)+(65535&b),d=(a>>16)+(b>>16)+(c>>16);return d<<16|65535&c}
				function c(a,b){return a<<b|a>>>32-b}
				function d(a,d,e,f,g,h){return b(c(b(b(d,a),b(f,h)),g),e)}
				function e(a,b,c,e,f,g,h){return d(b&c|~b&e,a,b,f,g,h)}
				function f(a,b,c,e,f,g,h){return d(b&e|c&~e,a,b,f,g,h)}
				function g(a,b,c,e,f,g,h){return d(b^c^e,a,b,f,g,h)}
				function h(a,b,c,e,f,g,h){return d(c^(b|~e),a,b,f,g,h)}
				function i(a,c){a[c>>5]|=128<<c%32,a[(c+64>>>9<<4)+14]=c;var d,i,j,k,l,m=1732584193,n=-271733879,o=-1732584194,p=271733878;for(d=0;d<a.length;d+=16)i=m,j=n,k=o,l=p,m=e(m,n,o,p,a[d],7,-680876936),p=e(p,m,n,o,a[d+1],12,-389564586),o=e(o,p,m,n,a[d+2],17,606105819),n=e(n,o,p,m,a[d+3],22,-1044525330),m=e(m,n,o,p,a[d+4],7,-176418897),p=e(p,m,n,o,a[d+5],12,1200080426),o=e(o,p,m,n,a[d+6],17,-1473231341),n=e(n,o,p,m,a[d+7],22,-45705983),m=e(m,n,o,p,a[d+8],7,1770035416),p=e(p,m,n,o,a[d+9],12,-1958414417),o=e(o,p,m,n,a[d+10],17,-42063),n=e(n,o,p,m,a[d+11],22,-1990404162),m=e(m,n,o,p,a[d+12],7,1804603682),p=e(p,m,n,o,a[d+13],12,-40341101),o=e(o,p,m,n,a[d+14],17,-1502002290),n=e(n,o,p,m,a[d+15],22,1236535329),m=f(m,n,o,p,a[d+1],5,-165796510),p=f(p,m,n,o,a[d+6],9,-1069501632),o=f(o,p,m,n,a[d+11],14,643717713),n=f(n,o,p,m,a[d],20,-373897302),m=f(m,n,o,p,a[d+5],5,-701558691),p=f(p,m,n,o,a[d+10],9,38016083),o=f(o,p,m,n,a[d+15],14,-660478335),n=f(n,o,p,m,a[d+4],20,-405537848),m=f(m,n,o,p,a[d+9],5,568446438),p=f(p,m,n,o,a[d+14],9,-1019803690),o=f(o,p,m,n,a[d+3],14,-187363961),n=f(n,o,p,m,a[d+8],20,1163531501),m=f(m,n,o,p,a[d+13],5,-1444681467),p=f(p,m,n,o,a[d+2],9,-51403784),o=f(o,p,m,n,a[d+7],14,1735328473),n=f(n,o,p,m,a[d+12],20,-1926607734),m=g(m,n,o,p,a[d+5],4,-378558),p=g(p,m,n,o,a[d+8],11,-2022574463),o=g(o,p,m,n,a[d+11],16,1839030562),n=g(n,o,p,m,a[d+14],23,-35309556),m=g(m,n,o,p,a[d+1],4,-1530992060),p=g(p,m,n,o,a[d+4],11,1272893353),o=g(o,p,m,n,a[d+7],16,-155497632),n=g(n,o,p,m,a[d+10],23,-1094730640),m=g(m,n,o,p,a[d+13],4,681279174),p=g(p,m,n,o,a[d],11,-358537222),o=g(o,p,m,n,a[d+3],16,-722521979),n=g(n,o,p,m,a[d+6],23,76029189),m=g(m,n,o,p,a[d+9],4,-640364487),p=g(p,m,n,o,a[d+12],11,-421815835),o=g(o,p,m,n,a[d+15],16,530742520),n=g(n,o,p,m,a[d+2],23,-995338651),m=h(m,n,o,p,a[d],6,-198630844),p=h(p,m,n,o,a[d+7],10,1126891415),o=h(o,p,m,n,a[d+14],15,-1416354905),n=h(n,o,p,m,a[d+5],21,-57434055),m=h(m,n,o,p,a[d+12],6,1700485571),p=h(p,m,n,o,a[d+3],10,-1894986606),o=h(o,p,m,n,a[d+10],15,-1051523),n=h(n,o,p,m,a[d+1],21,-2054922799),m=h(m,n,o,p,a[d+8],6,1873313359),p=h(p,m,n,o,a[d+15],10,-30611744),o=h(o,p,m,n,a[d+6],15,-1560198380),n=h(n,o,p,m,a[d+13],21,1309151649),m=h(m,n,o,p,a[d+4],6,-145523070),p=h(p,m,n,o,a[d+11],10,-1120210379),o=h(o,p,m,n,a[d+2],15,718787259),n=h(n,o,p,m,a[d+9],21,-343485551),m=b(m,i),n=b(n,j),o=b(o,k),p=b(p,l);return[m,n,o,p]}
				function j(a){var b,c="";for(b=0;b<32*a.length;b+=8)c+=String.fromCharCode(a[b>>5]>>>b%32&255);return c}
				function k(a){var b,c=[];for(c[(a.length>>2)-1]=void 0,b=0;b<c.length;b+=1)c[b]=0;for(b=0;b<8*a.length;b+=8)c[b>>5]|=(255&a.charCodeAt(b/8))<<b%32;return c}
				function l(a){return j(i(k(a),8*a.length))}
				function m(a,b){var c,d,e=k(a),f=[],g=[];for(f[15]=g[15]=void 0,e.length>16&&(e=i(e,8*a.length)),c=0;16>c;c+=1)f[c]=909522486^e[c],g[c]=1549556828^e[c];return d=i(f.concat(k(b)),512+8*b.length),j(i(g.concat(d),640))}
				function n(a){var b,c,d="0123456789abcdef",e="";for(c=0;c<a.length;c+=1)b=a.charCodeAt(c),e+=d.charAt(b>>>4&15)+d.charAt(15&b);return e}
				function o(a){return unescape(encodeURIComponent(a))}
				function p(a){return l(o(a))}
				function q(a){return n(p(a))}
				return q(a);
			},
			
			//msg
			msg:function(opts){
				if(k.index.msg){
					k.index.msg.card.cancel();
				}
				return k.index.msg = new function kmsg(){
					this.opts = k._f.optionsInput(opts,{
						timeOut:2500,
						type:'echo',
						position:'center',
						class:'card-msg',
						format:['body'],
						success:null,//关闭的执行方法
						zIndex:99,
					},'text');
					this.opts.content = '<div style="padding: 5px 15px;background-color: #6b6b6b;color: #fff;">'+(this.opts.text?this.opts.text:"")+'</div>';
					this.card = new k._f.card(this.opts);
					this.card.format.card.css({
						'border':'none',	
						'border-radius':'5px',	
						'overflow':'hidden',
						'background':'none'
					});
					this.card.format.body.css("overflow","unset");
					var ths = this;
					setTimeout(function(){
						ths.card.cancel();
						ths.opts.success&&ths.opts.success();
						},this.opts.timeOut);
				}
			},
			
			pageBack:function(id,data){
				var prc = k.message.get(id);
				if(prc){
					prc.opts&&prc.opts.pageBack(data);
				}else{
					var iframeid = $Q('html').attr('data-iframeid');
					if(iframeid){
						 prc = k.message.get(iframeid);
						 prc&&prc.opts&&prc.opts.pageBack(data);
					}
				}
			},
			
			pageClose:function(id,data){
				var prc = k.message.get(id);
				prc&&prc.card&&prc.card.cancel();
			},
			
			//prompt,文本输入弹窗信息
			prompt:function(opts){
				return new function kprompt(){
					this.opts = k._f.optionsInput(opts,{
						tips:'信息输入',
						width:'400px',
						autoCreate:false,
						text:'',
						type:'input',//支持input,textarea
						class:'card-prompt',
						value:'',
						sure:function(){return true;},
						cancel:function(){return true;},
					});
					this.opts.content = '<div style="margin:15px;"><div>'+(this.opts.text?this.opts.text:"")+'</div><div style="margin-top: 10px;">'+((function(ths){
						switch(ths.opts.type){
							case 'textarea':return '<textarea style="max-width: 100%;min-width: 100%;line-height: 26px;box-sizing: border-box;margin: 0px;max-height: 80px; min-height: 45px;padding: 10px;outline: none;border: 1px solid #dedede;outline-color: #cdcdcd;padding-left: 0.5em;padding-right: 0.5em;" data-api-value>'+(ths.opts.value?ths.opts.value:"")+'</textarea>';
							default:return '<input style="width: 100%;max-width: 100%;min-width: 100%;line-height: 26px;box-sizing: border-box;border: 1px solid #dedede;outline-color: #cdcdcd;padding-left: 0.5em;padding-right: 0.5em;" data-api-value value="'+(ths.opts.value?ths.opts.value:"")+'" />';	
						}
						})(this))+'</div></div>';
					this.card = new k._f.card(this.opts);
					this.card.beforeCreate = function(){
						var ths = this;
						var btn = k._e_e.selector('<button type="button" style="margin: 5px;vertical-align: bottom;box-sizing: border-box;background-color: unset;border: 1px solid #dedede;border-radius: 5px;padding: 5px 10px;opacity: 0.95;cursor: pointer;">确定</button>');
						var btn2 = k._e_e.selector('<button type="button" style="margin: 5px;vertical-align: bottom;box-sizing: border-box;background-color: #fafafa;border: 1px solid #dedede;border-radius: 5px;padding: 5px 10px;opacity: 0.95;cursor: pointer;">取消</button>');
						btn.click(function(){
							var val = ths.card.find('[data-api-value]').val();
							ths.opts.sure(val);
							ths.format.closeIcon.click();	
						})
						btn2.click(function(){
							ths.opts.cancel();
							ths.format.closeIcon.click();	
						})
						var box = k._e_e.selector('<div style="text-align:center;margin: 10px;"></div>');
						box.append(btn);
						box.append(btn2);
						this.format.foot.append(box);
					}
					this.card.create();
				}	
			},
			//退出全屏按钮
			quitFullscreen:function(callback){
				if (document.exitFullscreen) {
					document.exitFullscreen();
				}
				else if (document.msExitFullscreen) {
					document.msExitFullscreen();
				}
				else if (document.mozCancelFullScreen) {
					document.mozCancelFullScreen();
				}
				else if (document.webkitCancelFullScreen) {
					document.webkitCancelFullScreen();
				}
				document.onfullscreenchange = function(){
					callback&&callback();
				}
			},
			
			//创建一个卡片
			card:function(opts){
				opts = k._f.optionsInput(opts,{
					tips:'',//标题
					format:['head','body','foot'],//展示元素组键集合
					//card创建成功返回
					callback:function(data){ console.log('card创建成功返回');},
					//关闭返回,返回 ture为关闭成功，否则自定义关闭
					cancel:function(){ return true;},
					//常规执行按钮
					sure:function(){return true;},
					
					autoCreate:true,
					//body内容
					content:'',
					//配置额外的class
					class:'',
					//卡片宽度
					width:'auto',
					//卡片高度
					height:'auto',
					//卡片位置居中,
					position:'c',//c:[c,t,r,b,l,tr,tl,br,bl];
					//卡片背景点击
					backgroundClick:function(){},
					
					hasBgcolor:true,//是否有背景图片
					
					zIndex:0,
					//背景信息
					bgColor:null,//背景颜色
				});
				return new function Kcard(){
					//参数信息
					var ths = this;
					this.opts = opts;
					this.ww = window.innerWidth;
					this.wh = window.innerHeight;
					this.maxh = 0;
					this.formatH = {
						head:k._config.CARD_HEAD_H,
						foot:k._config.CARD_FOOT_H,	
					}
					this.beforeCreate = function(){};
					
					//卡片信息
					this.card = '';
					
					//图层信息
					this.format = {
						closeIcon:((function(ths){
							return k._e_e.selector(k._f.parseHTML('<span style="position: absolute;right: 0px;width: 16px;height: 16px;margin: 8px;border-radius: 50%;transform: rotateZ(45deg);"><span style="position: absolute;width: 2px;height: 100%;background: #333;left: calc(50% - 1px);"></span><span style="position: absolute;width: 100%;height: 2px;background: #333; top: calc(50% - 1px);"></span></span>'));
							})(this)),
						head:((function(ths){
							return k._e_e.selector(k._f.parseHTML('<div class="card-head" style="width: 100%;position: relative;height: '+ths.formatH.head+'px;border-bottom: 1px solid #dedede;background-color: #fafafa;box-sizing: border-box;"><span style="line-height: '+ths.formatH.head+'px;margin-left: 10px;font-weight: 600;color:#1a1a1a">'+(opts.tips?opts.tips:"")+'</span></div>'));
							})(this)),
						body:((function(ths){
							return k._e_e.selector(k._f.parseHTML('<div  class="card-body" style="min-height: 26px;overflow: auto;box-sizing: border-box;position: relative;"></div>'));
							})(this)),
						foot:((function(ths){
							return k._e_e.selector(k._f.parseHTML('<div class="card-foot" style="min-height: '+ths.formatH.foot+'px;border-top: 1px solid #dedede;box-sizing: border-box;"></div>'));
							})(this)),
						cardbg:((function(ths){
							var ele = k._e_e.selector(k._f.parseHTML('<div class="card card-full-bg" style="position: fixed;left: 0;top: 0;right: 0;bottom: 0;z-index:'+opts.zIndex+';'+(opts.bgColor?('background:'+opts.bgColor):'')+';border-radius: 0;"></div>'));
							$Q(ele).on('click',function(){
								ths.opts.backgroundClick();
								});
							return ele;
							})(this)),
						card:((function(ths){
							return k._e_e.selector(k._f.parseHTML('<div class="card card-api '+opts.class+'" style="position:fixed;width:'+opts.width+';height:'+opts.height+';border-radius: 2px;background: #fff;box-shadow: 0px 0px 2px #ccc;min-width: 32px;max-width:'+window.innerWidth+'px;max-height:'+window.innerHeight+'px;z-index:'+opts.zIndex+'"></div>'));
							})(this)),
					},
					
					//重置位置信息
					this.resetPosition = function(){
						var w = this.format.card.width();
						var h = this.format.card.height();
						switch(this.opts.position){
							case 't':((function(ths){
								ths.format.card.css('left',((ths.ww - w )/2)+"px");
								ths.format.card.css('top',"0px");
								})(this));break;
							case 'r':((function(ths){
								ths.format.card.css('left',((ths.ww - w ))+"px");
								ths.format.card.css('top',((ths.wh - h )/2)+"px");
								})(this));break;	
							case 'b':((function(ths){
								ths.format.card.css('left',((ths.ww - w )/2)+"px");
								ths.format.card.css('top',((ths.wh - h ))+"px");
								})(this));break;
							case 'l':((function(ths){
								ths.format.card.css('left',"0px");
								ths.format.card.css('top',((ths.wh - h )/2)+"px");
								})(this));break;
							case 'tr':((function(ths){
								ths.format.card.css('left',((ths.ww - w ))+"px");
								ths.format.card.css('top',"0px");
								})(this));break;
							case 'tl':((function(ths){
								ths.format.card.css('left',"0px");
								ths.format.card.css('top',"0px");
								})(this));break;
							case 'br':((function(ths){
								ths.format.card.css('left',((ths.ww - w ))+"px");
								ths.format.card.css('top',((ths.wh - h ))+"px");
								})(this));break;
							case 'bl':((function(ths){
								ths.format.card.css('left',"0px");
								ths.format.card.css('top',((ths.wh - h ))+"px");
								})(this));break;
							default:((function(ths){
								ths.format.card.css('left',((ths.ww - w )/2)+"px");
								ths.format.card.css('top',((ths.wh - h )/2)+"px");
								})(this));
						}
						//重置页面body高度
						var ch = this.format.card.height();
						var lh = parseInt(ch) - this.maxh;
						this.format.body.css('max-height',lh+"px");
						this.format.body.css('height',lh+"px");
					}
					this.callback = null;
					this.create = function(){
						this.beforeCreate();
						var ths = this;
						this.format.head.append(this.format.closeIcon);
						this.format.body.append(this.opts.content);
						this.maxh = 0;
						for(var i =0;i < this.opts.format.length;i++){
							this.format.card.append(this.format[this.opts.format[i]]);
							var h = this.formatH[this.opts.format[i]];
							h&&(this.maxh+=h);
						}
						this.card = this.format.cardbg;
						this.card.append(this.format.card);
						this.format.closeIcon.click(function(){
							ths.cancel();
						});
						k._e_e.selector('body').append(this.card);
						this.resetPosition();
						this.callback = this.opts.callback;
						this.callback();
					}
					
					//关闭当前弹窗
					this.cancel = function(){
						if(this.opts.cancel()){this.card.remove();}
					}
					
					//执行
					this.sure = function(){
						if(this.opts.sure()){this.card.remove();}	
					}
					
					this.opts.autoCreate&&this.create();
				}
				return card;
			},
			
			//创建简单元素
			createElement:function(tagName){
				return document.createElement(tagName);
			},
			
			//error
			error:function(msg){
				console.warn('$Q.error:'+msg);
			},
			
			//文件大小转字符串,根据字符串转文件大小
			//文件字节转文本大小
			filebyte2size:function(b){
				b = parseInt(b);
				var u = '';
				if(b/1024>1){
					b = b/1024;
					u = "k";
				}
				if(b/1024>1){
					b = b/1024;
					u = "m";
				}
				return parseFloat(b).toFixed(2).toString() + u;
			},
			//文件文本大小转字节大小
			//已解析k,m
			filesize2byte:function(t){
				t = k._f.strtolower(t);
				var b = 1;//倍率
				t = t.replace(/[km]/,function(r1){
					if(r1 == 'm'){
						b = 1048576;
					}else if(r1=='k'){
						b = 1024;	
					}
					return '';
				});
				return parseFloat(t) * b;
			},
			
			//关于模拟表单的部分
			form:function(options){
				var ths = this;
				//基础的元素列表信息
				this.element = null;
				//临时form表单信息
				this.tmp_form = null;
				//临时method
				this.tmp_method = 'get';
				this.tmp_action = '';
				this.tmp_enctype = 'multipart/form-data';
				this.tmp_target = 'self';
				
				//form表单的基础信息
				this.formdata = new FormData();
				
				//增加一个参数信息
				this.append = function(n,v){
					this.formdata.append(n,v);
				};
				
				//设置请求参数
				this.setAction = function(action){
					this.tmp_action = action;	
				}
				//设置请求方式
				this.setMethod = function(method){
					this.tmp_method = method;	
				}
				//配置enctype
				this.setEnctype = function(enctype){
					this.tmp_enctype = enctype;
				}
				//配置详细新目标
				this.setTarget = function(target){
					this.tmp_target = target;	
				}
				//打开新的窗口
				this.isNew = function(){
					this.tmp_target = 'new';	
				}
				
				//设置form表单的请求头
				this.setHeaders = function(){}
				
				//提交表单
				//提交表单到某个指定的链接地址
				this.submit = function(){
					if(this.tmp_form){
						//已经有表单信息了,执行表单的提交
						k._e_e.selector(this.tmp_form).submit();
					}else{
						//没有表单信息
						this.install();
						this.submit();	
					}
				}
				//清除已有的表单信息
				this.clear = function(){
					return this.tmp_form?this.tmp_form.remove():'';	
				}
				
				//卸载
				this.uninstall = function(){
					this.clear();	
				}
				
				//初始化当前表单，实例化
				//是不需要显示出来的
				this.install = function(isShow){
					this.clear();
					isShow = isShow?isShow:0;
					this.tmp_form = k._e_e.selector('<form></form>');
					k._e_e.selector('body').append(this.tmp_form);
					ths.tmp_form.append('<label style="display: block;"><span>请求地址：'+this.tmp_action+'</span></label>');
					ths.tmp_form.append('<label style="display: block;"><span>请求方式：'+this.tmp_method+'</span></label>');
					this.formdata.forEach(function(v,n){
						ths.tmp_form.append('<label style="display: block;"><span>'+n+'</span><input name="'+n+'" value="'+v+'" /></label>');
					})
					this.tmp_form.attr('action',this.tmp_action);
					this.tmp_form.attr('method',this.tmp_method);
					this.tmp_form.attr('enctype',this.tmp_enctype);
					this.tmp_form.attr('target',this.tmp_target)
					if(isShow){
						this.tmp_form.show();
					}else{
						this.tmp_form.hide();	
					}
				}
				
				//打印信息
				this.print = function(){
					return this.install(1);
				}
				
				//执行初始化内容
				this.init = function(options){
					//判定输入的类型
					if(Object.prototype.toString.call(options)=='[object HTMLFormElement]'){
						//form表单的具体内容
						this.element = options;
						//请求的内容信息获取
						this.setMethod(k._e_e.selector(this.element).attr('method'));
						this.setAction(k._e_e.selector(this.element).attr('action'));
						this.setEnctype(k._e_e.selector(this.element).attr('enctype'));
						this.setTarget(k._e_e.selector(this.element).attr('target'));
					}else{
						return k.debug('function customized');	
					}
				};
				//执行初始化
				this.init(options);
			},
			
			//get请求
			get:function(url,type,success,error){
				return $Q.ajax({
					url:url,
					dataType:type,
					type:'get',
					success:success,
					error:error
				});
			},
			
			//将代码字符串转换为直接显示的那种字符串
			html2text:function(s,c){
				return s.toString().replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/'/g, "&#39;");
			},
			
			isDev:false,//测试专属字段
			
			//判定是否全屏信息
			isFullscreen:function(){
				return !!(
					document.fillscreen ||
					document.modFulIScreen ||
					document.webkitIsFullScreen ||
					document.webkitFullScreen ||
					document.msFullScreen
				);
			},
			
			//判定IOS还是Android
			isIOS:((function(){
				var ua = navigator.userAgent;
				return!!ua.match(/(i[^;]+;( U;)? CPU.+Mac OS X)/);	
			})()),
			//动态判定是否为IOS设备
			isIos:function(){
				var ua = navigator.userAgent;
				return!!ua.match(/(i[^;]+;( U;)? CPU.+Mac OS X)/);	
			},
			
			//判定是否为移动设备
			isMobile:((function(){
				var ua = navigator.userAgent;
				if(ua.match(/Android/i)
					|| ua.match(/webBos/i)
					|| ua.match(/iPhone/i)
					|| ua.match(/iPad/i)
					|| ua.match(/iPod/i)
					|| ua.match(/BlackBerry/i)
					|| ua.match(/Windows Phone/i)
				){
					return true;
					}
					return false;
			})()),
			
			jsonDecode:function(s){return k._f.parseJSON(s);},
			jsonEncode:function(o){return k._f.stringifyJSON(o);},
			//loading及相关信息
			loading:function(isShow){
				(isShow===false)?((function(ths){
					ths.loadingEnd();	
				})(this)):((function(ths){
					k._f.config('LOADING_IMG')?ths.loadingStartwithimg({
							img:k._f.config('LOADING_IMG'),
							rotate:k._f.config('LOADING_IMG_PROTATE'),
							scale:k._f.config('LOADING_SCALE'),
							timer:k._f.config('LOADING_TIMER')
						}):ths.loadingStart();	
				})(this))
			},	
			
			loadingStartwithimg:function(opts){
				return new function Kloading(){
					this.opts = k._f.optionsInput(opts,{
						format:['body'],
						zIndex:'6519101',
						class:'card-loading',
						autoCreate:false,
					});
					this.card = new k._f.card(this.opts);
					this.card.box1 = k._e_e.selector('<div style="width: 120px;height: 120px;position: relative;border-radius: 50%;box-sizing: content-box;overflow: hidden;"></div>');
					this.card.box2 = k._e_e.selector('<img style="width: 120px;height: 120px;" src="'+opts.img+'"/>');
					this.card.box1.append(this.card.box2);
					this.card.box2.animation({
						animationType:opts.scale,
						rotateZspeed:opts.rotate,	
						timer:opts.timer
					})
					this.card.format.body.append(this.card.box1);
					this.card.format.card.css({
						'border':'none',
						'box-shadow':'none',
						'background':'none',
					});
					this.card.create();
					k._loading = this;
				}

			},
			loadingStart:function(){
				return new function Kloading(){
					this.opts = k._f.optionsInput({},{
						format:['body'],
						autoCreate:false,
					});
					this.card = new k._f.card(this.opts);
					this.card.box1 = k._e_e.selector('<div style="width: 120px;height: 120px;position: relative;border-radius: 50%;border: 5px solid #4eee71;box-sizing: content-box;overflow: hidden;"></div>');
					this.card.box2 = k._e_e.selector('<div style="width: 110px;height: 110px;border-radius: 50%;border: 5px solid #a0b;;box-sizing: border-box;position: absolute;border-left-color: #fff;overflow: hidden;left: 5px;top: 5px;border-right-color: #fff;"></div>');
					this.card.box3 = k._e_e.selector('<div style="width: 90px;height: 90px;position: relative;border-radius: 50%;border: 5px solid #3F51B5;box-sizing: border-box;border-left-color: #fff;border-right-color: #fff;overflow: hidden;position: absolute;left: 15px; top: 15px;"></div>');
					this.card.box4 = k._e_e.selector('<div style="width: 80px;height: 80px;position: relative;border-radius: 50%;border: 5px solid #4eee71;padding: 5px;box-sizing: border-box;overflow: hidden;position: absolute;left: 20px;top: 20px;border-top-color: #fff;border-bottom-color: #fff;"></div>');
					this.card.box5 = k._e_e.selector('<div style="width: 60px;height: 60px;border-radius: 50%;box-sizing: content-box;position: absolute;background-color: #fff;left: 25px;top: 25px;border: 5px solid #E91E63;line-height: 60px;font-size: 12px;text-align: center;"></div>');
					this.card.box1.append(this.card.box2);
					this.card.box1.append(this.card.box3);
					this.card.box1.append(this.card.box4);
					this.card.box1.append(this.card.box5);
					this.card.box4.animation({
						animationType:'circle',
						rotateZspeed:2,	
					})
					this.card.box3.animation({
						animationType:'circle',
						rotateZspeed:-4,
					})
					this.card.box2.animation({
						animationType:'circle',
						rotateZspeed:6,	
					})
					this.card.box5.text('loading..');
					this.card.format.body.append(this.card.box1);
					this.card.format.card.css({
						'border':'none',
						'box-shadow':'none',
						'background':'none',
					});
					this.card.create();
					k._loading = this;
				}
			},
			
			loadingEnd:function(){
				k._loading&&k._loading.card.cancel();
			},
			
			//loadcard
			loadpage:function(opts){
				opts = k._f.optionsInput(opts,{
					zIndex:0,
					url:'',
					tips:'-',
					class:'card-page',
					templateId: 'page_'+Math.ceil(Math.random() * 100000),
					width:window.innerWidth+"px",
					height:window.innerHeight+"px",
					//format:'iframe',//具体的实现逻辑【dom,iframe,iframe-body】
					data:{},
					iframe : ['head','body'],
					callback:function(){},//执行成功执行
					pageBack:function(){}//数据返回
				},'url');
				return new function Kpage(){
					this.opts = opts;
					opts.ths = this;
					var str = k._f.urlEncode(opts.data);
					opts.url = opts.url+ (str?('?'+str):'');
					this._iframe = k._e_e.selector('<iframe src="'+opts.url+'"></iframe>');
					this._iframe.first(true).onload = function(){
						$Q(this.contentDocument).find('html').attr('data-iframeid',opts.templateId);
					}
					this.opts.content = this._iframe;
					this._iframe.css({
						'position': 'relative',
						'width':'100%',
						'border':'none',
						'vertical-align':'bottom',
						'height':'-webkit-fill-available'
					});
					//自动创建卡片信息
					opts.autoCreate = true;
					this.card = k._f.card(opts);
					this.card.id = opts.templateId;
					var h = this.card.format.card.height() 
						- this.card.format.head.height()
						- this.card.format.foot.height();
					this._iframe.css({
						'height':(h)+'px',
					});
					//关闭当前卡片方法
					opts.cancel = function(){
						this.ths.card.cancel();	
					}
					k._f.setProcess(this.card.id,this);
				}
			},
			
			//常规转化
			optionsInput:function(options,initObject,defCode){
				var obejct = {};
				obejct['callback'] = function(){};
				obejct['success'] = function(){};
				obejct['error'] = function(){};

				obejct['version'] = k._e_e.version;
				for(var i in obejct){
					if(initObject[i]==undefined){
						initObject[i] = obejct[i];
					}
				}
				if(typeof(options)=='object'){
					if(Object.prototype.toString.call(options).indexOf('[object HTML')==0){
						var tmp = options;	
						options = {element:tmp};
					}
				}else{
					if(defCode==undefined){defCode='text'}
					var tmp = options;	
					options = {};
					if(tmp!=undefined){
						options[defCode] = tmp;
					}
				}
				for(var i in options){
					initObject[i]=options[i];	
				}
				return initObject;
			},
			
			//html
			parseHTML:function(a,justDom,plabel){
				plabel = plabel?plabel:'div';
				var e = document.createElement(plabel);
				e.innerHTML = a;
				return justDom?e.children:e.childNodes;
			},
			
			//json
			parseJSON:function(s){
				try{return JSON.parse(s+"")}catch(err){
					try{
						return eval(s);
					}catch(err){
						return null;	
					}
				}
			},
			
			//xml
			parseXML:function(xmlString){
				var xmlDoc;  
				if(typeof xmlString == "string") {  
					if(document.implementation.createDocument) {  
						var parser = new DOMParser();  
						xmlDoc = parser.parseFromString(xmlString, "text/xml");  
					}else if(window.ActiveXObject) {  
						xmlDoc = new ActiveXObject("Microsoft.XMLDOM");  
						xmlDoc.async = false; 
						xmlDoc.loadXML(xmlString);  
					}  
				}else {  
					xmlDoc = xmlString;  
				}  
				return xmlDoc;
			},
			
			//关于引用插件的那点事
			plugIn:{
				//注册插件的内容信息
				register:function(plugname,plugbody){
					this.info.push(plugname);
					this[plugname] = plugbody;
				},
				info:[],
				//关于时间的插件,时间自动跑的那种
				time:function(opts){
					opts.timestame = parseInt(opts.timestame);
					setInterval(function(){
						var date = new $Q.date({
							timeStamp:opts.timestame
						});
						k._e_e.selector(opts.boxElement).html(date.output());
						opts.timestame++;
					},1000);
				},
			},
			
			process:null,
			proxy:function(opts){
				k.debug('proxy init start','proxy');
				opts = k._f.optionsInput(opts,{
					action:'',//执行请求地址
					method:'get',//执行请求
					//返回数据类型
					//"",string,json,jsonp
					dataType:'',//
					data:{},
					//"",arraybuffer,blob,document,json,text,ms-stream
					responseType:'',
					success:function(){},//执行成功
					error:function(){},//执行失败
					progress:function(){},//当前执行进度
					header:{
						"X-Requested-With":"XMLHttpRequest"
					}
				});
				return new function Kproxy(){
					this.opts = opts;
					this.state = 0;
					this.dataType = k._f.strtoupper(this.opts.dataType);
					this.response = '';
					this.success = this.opts.success;
					this.error = this.opts.error;
					this._data = new FormData();
					this.upload = null;
					this.isSuccess = true;
					this.XMLHttpRequest = ((function(){
						return (window.XMLHttpRequest)
						?(new XMLHttpRequest()):((function(){
							try {
								return new ActiveXObject("Microsoft.XMLHTTP");
							}catch (e) {
								try {
									return new ActiveXObject("Microsoft.XMLHTTP");  
								}catch(er){console.log("创建代理对象错误")}
							}
						})());	
					})());
					this.emptyDatas=function(){ this._data = new FormData()},
					//配置上传的url部分
					this.setUrl = function(url){this.opts.action = url;}
					
					
					this.hasData = function(code){
						if(this._data.get(code)){return true}else{return false;}	
					}
					this.setData = function(n,v){
						if(Object.prototype.toString.call(v)=='[object Object]'||Object.prototype.toString.call(v)=='[object Array]'){
							this.setDataswithchild(v,n);
						}else{
							this._data.set(n,v);
						}	
					}
					this.setDataswithchild=function(datas,parCode){
						for(var i in datas){
							if(datas[i]&&(typeof(datas[i])=='object')){
								this.setDataswithchild(datas[i],parCode+"["+i+"]");	
							}else{
								this._data.append(parCode+"["+i+"]",datas[i]);	
							}
						}	
					},
					this.setDatas = function(datas){
						for(var i in datas){
							this.setData(i,datas[i]);	
						}
					}
					
					//处理返回数据信息
					this.responseDeal = function(xmlres){
						if((xmlres.status>=200)&&(xmlres.status<300)){
							this.isSuccess = true;	
						}else{
							this.isSuccess = false;
						}
						switch(this.dataType){
							case 'JSON':
								this.response = k._f.jsonDecode(xmlres.responseText);
								if(this.response==null){
									this.isSuccess = false;	
								}
							break;
							case 'BLOB':
								this.response = xmlres.response;
							break;
							default:this.response = xmlres.responseText;
						}
						if(this.isSuccess){
							this.success&&this.success(this.response);
						}else{
							this.error&&this.error();
						}
					}
					
					//上传组键的一些初始化
					this.uploadInit = function(){
						this.upload = this.XMLHttpRequest.upload;
						this.upload.startTime = null;
						this.upload.endTime = null;

						this.upload.speedmsg = 0;
						this.upload.speed = 0;
						this.upload.loadedSize = 0;
						this.upload.fileSize = 0;
						this.upload.perSize = '0%';
						this.upload.units = 'b/s';
						this.upload.onloadstart = function(q){
							this.endTime = this.startTime = new Date().getTime();
							this.fileSize = this.loadedSize = 0;
						};
						this.upload.onloadend = function(){}
						this.upload.onprogress = function(q){
							if(q.lengthComputable) {
								this.fileSize = q.total;//文件总大小
								this.perSize = Math.round(this.loadedSize / this.fileSize * 100) + "%";
								var nt = new Date().getTime(),
								pt = (nt-this.endTime)/1000;
								this.endTime = nt;
								var preload = q.loaded - this.loadedSize;
								this.speed = preload / pt;
								this.loadedSize = q.loaded;
								if(this.speed/1024>1){
									this.speed = this.speed/1024;
									this.units = "k/s";
								}
								if(this.speed/1024>1){
									this.speed = this.speed/1024;
									this.units = "M/s";
								}
								this.speed = this.speed.toFixed(2);
								this.speedmsg = this.speed+this.units;
								opts.progress&&opts.progress(this);
							}	
						}
					}
					
					//返回
					this.respose = null;
					
					//发送过程中推送数据流
					this.pushStream = function(){
						var ths = this;
						for(var i in ths.opts.header){
							this.XMLHttpRequest.setRequestHeader(i,ths.opts.header[i]);
						}
						this.XMLHttpRequest.responseType = this.opts.responseType;
						this.XMLHttpRequest.onreadystatechange = function(){
							ths.state = this.readyState;
							if(this.readyState==4){
								ths.responseDeal(this);
							}
						}	
						this.uploadInit();
					};
					
					//参数初始化【paramInit】
					this.paramInit = function(){
						var ths = this;
						this.opts.method = k._f.strtoupper(this.opts.method);
						switch(this.opts.method){
							case 'GET':
								//get的相关配置及操作
								//获取参数信息
								var getstr = '';
								this._data.forEach(function(v,n){
									if(getstr){
										getstr += '&'+n+'='+v;
									}else{
										getstr += n+'='+v;
									}
								});
								ths.noActionpram = true;
								this.opts.action = this.opts.action.replace(/(\?)(.*)$/,function(p1,p2,p3){
										ths.noActionpram = false;
										if(p3){
											return p2+p3+'&'+getstr;
										}else{
											if(getstr){
												return'?'+getstr;
											}else{
												return '';
											}
										}
									});
								if(ths.noActionpram&&getstr){
									this.opts.action += '?'+getstr;

								}
							;break;
							case 'POST':;break;
							default:;
						}
					}
					
					//发送数据信息
					this.send = function(){
						//配置参数信息
						this.setDatas(this.opts.data);
						this.paramInit();//参数初始化
						this.XMLHttpRequest.open(this.opts.method,this.opts.action,true);
						this.pushStream();
						this.XMLHttpRequest.send(this._data);
					}
				}
			},
			
			rand:function(){ return Math.random();},
			random:function(){
				return parseInt(Math.random() * 10000000 );
			},
			randRgb:function(){
				var c = parseInt(Math.random()*16).toString(16)
					+parseInt(Math.random()*16).toString(16)
					+parseInt(Math.random()*16).toString(16);
				return c;
			},
			
			setProcess:function(n,v){
				k.message.set(n,v);
			},
			//socket的正式版本
			socket:function(config){
				return new function KuoqiWebSocket (){
					this.config = k._f.optionsInput(config,{
						url:'ws:\/\/0.0.0.0:6519',//链接字符串
						//默认String,[支持string,json格式],如果使用json模式，返回非json的数据将被自动过滤掉，不会返回信息
						dataType:'',//返回的数据能使用的格式，
						data:{message:''},//额外的数据信息
						autoConnect:true,//是否为自动链接
						onOpen:null,//打开的时候触发本方法
						onError:null,//异常的监听
						onClose:null,//链接关闭的触发本方法
						onHeartbeat:null,//心跳检测触发本方法
						onHandle:null,//链接握手执行返回本方法
						onMessage:null,//收到信息触发本方法
						timeOut:5000,//默认超时时间
					},'url');
					//message-列表，params:每次发送信息传递的参数列表
					this.library = {message:[],ready:[],params:this.config.data};
					this.onOpen = this.config.onOpen;//执行打开成功的监听
					this.onError = this.config.onError;//异常的监听
					this.onClose = this.config.onClose;//关闭的监听
					this._callback = null;
					this.ready = function(ready){
						var ths = this;
						if(ready&&(typeof(ready)=='function')){
							this.library.ready.push(ready);
						}else{
							this.library.ready.forEach(function(func){
								ths._callback = func;
								ths._callback();
							});
						}
					}
					//获取当前状态信息
					this.stateMessage=function(){
						switch(this.socket.readyState){
							case 0:return "正在连接通讯";
							case 1:return "通讯连接成功";
							case 3:return "正在关闭通讯";
							default:return "通讯已关闭";	
						}
					},
					//绑定接收到信息
					this.onMessage = function(msg){
						var ths = this;
						this.library.message.forEach(function(func){
							ths._callback = func;
							ths._callback(msg);
						});
					};
					//接收消息的方法函数，这个是内部使用的
					this.message = function(rs){
						if(rs&&(typeof(rs)=='function')){
							this.library.message.push(rs);
						}
					}
					//关于接受到消息的模块的返回
					this.doMessage = function(rs){
						if(k._f.strtolower(this.config.dataType)=='json'){
							//json格式的数据
							this.onMessage(k._f.jsonDecode(rs.data));
						}else{
							//string根式的数据
							this.onMessage(rs.data);
						}
					},
					
					//这里是执行socket
					//创建的方法
					this.doConnect = function(){
						var ths = this;
						this.socket = new WebSocket(this.config.url);//打开服务端
						//open
						this.socket.onopen = function(evt){
							ths.onOpen&&ths.onOpen(evt);
							ths.ready();
						};
						//error
						this.socket.onerror = function(evt){
							ths.onError&&ths.onError(evt);
						};
						//close
						this.socket.onclose = function(evt){
							ths.onClose&&ths.onClose(evt);
						};
						//message
						this.socket.onmessage = function(evt){
							ths.doMessage&&ths.doMessage(evt);
						};
						setTimeout(function(){
							if(ths.socket.readyState==0){
								ths.socket.close();	
							}
						},this.config.timeOut);
					}
					
					//执行一个发送信息
					this.doSend = function(message){
						this.socket.send(message);
					}
					
					//执行一个send的完整信息
					this.send = function(cfg){
						if(!cfg){return null;}
						//参数信息
						if(typeof(cfg)!='object'){
							console.log('发送失败，请传入一个Hash进行发送数据请求');return;
						}
						var data = {};
						//装入参数基本信息
						for(var i in this.library.params){
							data[i] = this.library.params[i];	
						}
						//装入现在的用户信息
						for(var i in cfg){
							data[i] = cfg[i];
						}
						if(this.socket.readyState==1){
							var blob = new Blob(
								[k._f.jsonEncode(data)],
								{type: "application/octet-stream"}
							);
							this.doSend(blob);
						}else{
							console.warn(this.stateMessage());
						}	
					},
					//执行链接的方法
					//如果没有自动执行，请手动执行，使用this.doConnect();
					this.config.autoConnect&&this.doConnect();
				}
			},
			stringifyJSON:function(o){return JSON.stringify(o)},
			strspad:function(s,c,l){ return s.toString().padStart(l,c);},//左侧填补指定数据到长度
			strepad:function(s,c,l){ return s.toString().padEnd(l,c);},//右侧填补指定数据到指定长度
			strtoupper:function(s){ return s?s.toUpperCase():null;},
			strtolower:function(s){ return s?s.toLowerCase():null;},
			strtoworder:function(s){ return s.slice(0,1).toUpperCase()+ s.slice(1)},
			//时间格式化
			timeformat:function(code){
				var s = parseInt(code);
				var m = parseInt (s / 60 );
				s = s % 60;
				var h = parseInt(m / 60);
				m = m % 60;
				return (h?h:0) + ":" + (m?k._f.strspad(m,'0',2):'00') + ":" + (s?k._f.strspad(s,'0',2):'00');
			},
			//上传图片信息
			upload:function(opts){
				var opts = k._f.optionsInput(opts,{
					action:k._config.UPLOAD.ACTION,//上传文件地址
					multiple:false,//是否多文件上传，[true:是，false:否]
					secSize:k._config.UPLOAD.SEC_SIZE,//使用切片的话，切片大小
					data:k._config.UPLOAD.PARAMS,//额外绑定数据信息
					uploadname:'filename',//绑定上传文件名
					success:null,//请求成功执行
					error:null,//请求失败执行
					progress:null,//进度变更执行		
					cancel:null,//用户关闭上传执行
					compress:null,//压缩时候执行
				});
				if(opts.multiple){
					//多文件上传
					var files = new k._f.files();
					files.secSize = k._f.filesize2byte(Object(opts.secSize).toString());
					files.createBynone(function(){
						function getItemNeedupload(){
							for(var i = 0 ;i<files.files.length;i++){
								if(!files.files[i].isUpload){
									return files.files[i];
								}
							}
							return null;
						}
						function UploadOne(){
							var file = getItemNeedupload();
							if(file){
								//单个文件执行上传
								file.onsuccess = function(){
									//执行当前文件上传完成
									//继续执行下一个文件上传
									UploadOne();	
								};
								file.onerror = function(){
									//当前文件上传失败，继续执行下一个文件
									UploadOne();	
								};
								file.onprogress = function(){console.log('onprogress');};
								file.oncompress = function(){console.log('oncompress');};
								file.def_updata = opts.data;//默认上传数据放置
								file.uploadName = opts.uploadname;
								file.secSize = files.secSize;
								file.upload(opts.action);//文件上传
							}else{
								//执行返回的部分
								file.onsuccess = opts.success;
								file.onerror = opts.error;
								file.onprogress = opts.progress;
								file.oncompress = opts.compress;
							}
						}
						UploadOne();
					});	
				}else{
					//单文件上传
					var file = new k._f.file();
					file.onsuccess = opts.success;
					file.onerror = opts.error;
					file.onprogress = opts.progress;
					file.oncompress = opts.compress;
					file.def_updata = opts.data;//默认上传数据放置
					file.uploadName = opts.uploadname;
					file.secSize = k._f.filesize2byte(Object(opts.secSize).toString());
					file.createBynone(function(){
						file.upload(opts.action);	
					});	
				}
			},
			
			urlDecode:function(code){
				var arr = [];
				var tml = code.split('&');
				for(var i = 0;i<tml.length;i++){
					var tmp = tml[i].split('=');
					arr[tmp[0]] = tmp[1]?tmp[1]:null;
				};
				return arr;
			},
			
			urlEncode:function(code){
				var str = '';
				for(var i in code){
					if(str){
						str += '&'+i+'='+code[i];	
					}else{
						str += i+ '=' + code[i];	
					}
				};
				return str;
			},
			
			//验签数据
			//简单的验证常规数据信息
			//简单的返回成功和失败即可
			//暂时未计入文档
			validata:function(type,data){
				type = k._f.strtolower(type);
				switch(type){
					//手机号码验签
					case 'tel':return /^1[\d]{10}$/.test(data);
					default:return true;	
				}
			},
		},
		
		//核心相关配置
		init:function(a,b){
			if(b===true){
				k.init.__proto__ = k._f;
				return k.init;
			}
			if(typeof(k.init)=='function'){
				return k._e_e.selector(a,b);
			}
		},
		
		//拥有的属性方法们
		exports:{},	
	};
	window.$Q = window.kuoqiJs  = new k.init(true,true);
	window.$Q.process = k.message;
})());